/*
 *Description:
 *User:laoHu
 *Created with Intellij IDEA 2025
 *Data:2025.0.136
 *Time:14:44
 */

import book.Book;
import book.Booklist;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

public class Main{

    //登录界面
public static User login(){

    Scanner scanner = new Scanner(System.in);
    System.out.print("请输入你的名字：>");
    String name = scanner.nextLine();

    System.out.println("请选择你的身份：> 1.管理员  2.普通用户");
    System.out.print("请选择：>");
    int choice = scanner.nextInt();

    //判断
    if(choice == 1){
        return new AdminUser(name);
    }else {
        return new NormalUser(name);
    }
}

    public static void main(String[] args) {

    //加载书籍
        Booklist booklist = new Booklist();
    //登录页面接收返回值
     User user = login();

     //调用功能
        while(true){
            //加载选择并记录选项
            int choice =  user.menu();
            if (choice <= 4)
            user.iOperatioms[choice].work(booklist);
            else
                System.out.println("非法输入。请重新选择！！！");

        }
    }
}
